
//***********************************************************
//***********************************************************
//***********************************************************
//***********************************************************
//***********************************************************
//MAIN LOGIC HERE
//This is the main code that calls all other functions
//Keep this as the last function to make it easy to find logic
//***********************************************************
//***********************************************************
//***********************************************************
//***********************************************************
//***********************************************************
	
function logic()
	{
	//prioritize heal if < killhealth but > 19
	if (GM_getValue('autoHeal', '') == "checked" && health < killhealth && health > 19  && flag==0)
		{
		heal()
		}
//	if (experiencetolevel < 7 && energy >= experiencetolevel && flag==0)
//	if (flag==0)
//		{
//		useenergytolevel()
//		}
	// if energy >= max, prioritize burning it off
	if (energy >= maxenergy  && GM_getValue('autoMission', '') == "checked" && flag==0)
		{
		runmissions()
		}
	// if stamina = max, prioritize burning it off, health killhealth will drop through
	if (stamina >=  maxStamina && GM_getValue('autoFight', '') == "checked" && health > killhealth && flag==0)
		{
		if (fightUsers.length > 0)
			{
			fight()
			}
		else
			{
			scanfightlist()
			}
		}
	// normal heal
	if (GM_getValue('autoHeal', '') == "checked" && (health < GM_getValue('healthLevel', '')) && flag == 0)
		{
		heal()
		}
	// check on your pet if petvisit == 0
	if ((GM_getValue('autoBank', '') == "checked")&&(gold > parseInt(GM_getValue('bankConfig',0))) && (gold > 10) && (gold > parseInt(GM_getValue('bankKeep',0))+10) && flag==0)
		{
		bank()
		}
	if (GM_getValue('autoPet','') == "checked" && petvisit == 0 && flag==0)
		{
		feedandpet()
		}
	if (GM_getValue('autoFight', '') == "checked" && stamina>GM_getValue('fightMinimum',0) && flag==0)
		{
		if (fightUsers.length > 0)
			{
			fight()
			}
		else
			{
			scanfightlist()
			}
		}
	if (GM_getValue('autoMission', '') == "checked" && flag==0)
		{
		runmissions()
		}
	if (GM_getValue('autoIsland', '') == "checked" && flag==0)
		{
		autoisland()
		}
	if (GM_getValue('autoProperty', '') == "checked" && gold >= 10*GM_getValue('nextProperty', 0) &&flag==0)
		{
		buyproperties()
		}
	if (GM_getValue('autoTreasure','') == "checked" && flag==0)
		{
		autotreasure()
		}
	if (GM_getValue('autoStats', '') == "checked" && flag==0)
		{
		autostats()
		}
	flag = 1;
	}// comment so make.bat EOF character doesn't break script